package leetcode;

import java.util.Arrays;

class Solution_455 {
    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int i = g.length -1;
        int j = s.length -1;
        while (j >=0 && i >= 0) {
            if (s[j] >= g[i]){
                i --;
                j --;
            }else {
                i --;
            }
        }
        return s.length -1 - j;
    }

    public static void main(String[] args) {
        Solution_455 test = new Solution_455();
        System.out.println(test.findContentChildren(new int[]{1,2,3},new int[]{1,1}) == 1);
        System.out.println(test.findContentChildren(new int[]{1,2},new int[]{1,2,3}) == 2);
    }
}